package com.readaloud.wicket;

import org.apache.wicket.Component;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.protocol.http.WebSession;
import org.apache.wicket.request.mapper.parameter.PageParameters;


@SuppressWarnings("unused")
public class SearchPanel extends Panel {

	private static final long serialVersionUID = -4193482962608288298L;
	
	public SearchPanel(String id) {
		super(id);
		add(new SearchForm("searchForm"));
	}

	private class SearchForm extends Form<Component> {

		private static final long serialVersionUID = 9142506655979020833L;
		private String searchBook;

		public SearchForm(String id) {
			super(id);
			add(new TextField<String>("searchBook", new PropertyModel<String>(this, "searchBook")));
			setMarkupId("search-form");
		}
		
		@Override
		protected void onSubmit() {
            PageParameters params = new PageParameters();
            params.add("searchBook", getSearchBook());
            setResponsePage(ListBooks.class, params);
		}

		public String getSearchBook() {
			return searchBook;
		}

		public void setSearchBook(String searchBook) {
			this.searchBook = searchBook;
		}

	}
}
